Unknown Homeland cases topic modelling:¶

Import data set:¶

(9359, 5)

Dataset preprocessing:¶

Cases of Unknown Homeland (Ukendt hjemland) are kept.

Below we see the shape and head of the dataset.

(192, 1)
text
224 Nævnet stadfæstede i november 2021 Udl...
451 Nævnet stadfæstede i juni 2021 Udlændi...
487 Nævnet stadfæstede i juni 2021 Udlændi...
930 Nævnet stadfæstede i december 2020 Udl...
1320 Nævnet hjemviste i juni 2020 Udlænding...

Check for potential duplicates and drop them:

text
1362 Nævnet stadfæstede i maj 2020 Udlændin...
1381 Nævnet stadfæstede i maj 2020 Udlændin...
4035 Nævnet stadfæstede i januar 2018 Udlæn...
4036 Nævnet stadfæstede i januar 2018 Udlæn...
4090 Nævnet stadfæstede i januar 2018 Udlæn...
4093 Nævnet stadfæstede i januar 2018 Udlæn...

New shape for dataset after droping duplicate entries.

(189, 1)

Use a pipeline to pre-process the texts:¶

The pipeline consists of the following steps:

  • Lowercase all characters
  • Drop numbers
  • Remove punctuation
  • Remove stopwords. The list of stopwords can be found here.
  • Single letter words are dropped, too.
  • Tokenization
  • Lemmatization. The process during which all words are turned into its roots.

Steps can be added or removed from the pipeline.

text tokens num_tokens
224 Nævnet stadfæstede i november 2021 Udl... [stadfæste, udlændingestyrels, afgørelse, vedr... 319
451 Nævnet stadfæstede i juni 2021 Udlændi... [stadfæste, udlændingestyrels, afgørelse, vedr... 215
487 Nævnet stadfæstede i juni 2021 Udlændi... [stadfæste, udlændingestyrels, afgørelse, vedr... 309
930 Nævnet stadfæstede i december 2020 Udl... [stadfæste, udlændingestyrels, afgørelse, vedr... 180
1320 Nævnet hjemviste i juni 2020 Udlænding... [hjemvise, udlændingestyrels, afgørelse, vedrø... 315

Analysis:¶

Topic Modelling:¶

Latent Dirichlet Allocation (LDA):¶

The coherence score for LDA (0.78) is highest with 10 topics.

Build the model with the best number of topics and see them:

Topic 00
 bidoon (1.46)
 navn (1.34)
 ansøgere (1.09)
 år (0.90)
 bo (0.88)

Topic 01
 kvindelig (2.39)
 demonstration (1.24)
 dag (1.11)
 asylsamtale (1.04)
 bemærke (1.04)

Topic 02
 kvindelig (1.94)
 demonstration (1.70)
 videre (1.40)
 oplysnings (1.34)
 angiveligt (1.30)

Topic 03
 demonstration (1.95)
 bidoon (1.60)
 oplysning (1.29)
 deltage (1.15)
 barn (1.14)

Topic 04
 klager (1.83)
 libanon (1.22)
 ihjel (1.09)
 oplysning (1.08)
 ansøgere (1.08)

Topic 05
 eritrea (3.31)
 sudan (1.55)
 bopæl (1.23)
 flertal (1.15)
 mor (1.10)

Topic 06
 dag (2.49)
 kvindelig (1.98)
 gang (1.53)
 bopæl (1.35)
 tage (1.13)

Topic 07
 klager (9.49)
 opholdstilladelse (2.55)
 udlændingestyrelse (1.37)
 danmark (1.28)
 klagere (1.20)

Topic 08
 ægtefælle (2.83)
 demonstration (2.35)
 deltage (1.87)
 bror (1.44)
 bopæl (1.27)

Topic 09
 demonstration (2.49)
 bidoon (1.94)
 deltage (1.64)
 divergere (1.50)
 dag (1.40)

Visualise the topics produced by LDA:

Each bubble in the plot represents a topic. The size of the bubble represents the proportion of cases that contain the topic, with a larger bubble corresponding to a higher proportion.

The distance between the bubbles represents the similarity between the topics; the shorter the distance, the more similar the topics.

The bars in the bar chart represent the term frequency for each of the words. The blue bars show the overall term frequency in the collection of documents, whereas the red bars show the term frequency for the selected topic.

Non-Negative Matrix Factorization:¶

The coherence score for NMF (0.78) is highest with 10 topics.

Build the model with the best number of topics and see them:

The numbers inside the parentheses are the percentages with which the words contribute to the topics.

Topic 00
 demonstration (7.41)
 deltage (4.72)
 bidoon (2.06)
 dag (1.71)
 tilbageholde (1.62)

Topic 01
 klager (12.38)
 opholdstilladelse (3.22)
 klagere (1.65)
 danmark (1.41)
 nr (1.32)

Topic 02
 dag (2.95)
 bopæl (2.95)
 gang (2.62)
 tage (2.16)
 ægtefæll (1.85)

Topic 03
 ægtefælle (2.91)
 bidoon (2.50)
 ansøgere (2.36)
 navn (1.64)
 nærmere (1.55)

Topic 04
 kvindelig (2.58)
 demonstration (1.94)
 videre (1.88)
 oplysnings (1.71)
 bopæl (1.60)

Topic 05
 eritrea (5.83)
 sudan (2.83)
 år (2.37)
 eritreisk (1.54)
 etiopien (1.36)

Topic 06
 barn (2.39)
 oplysning (1.67)
 bidooner (1.53)
 sag (1.33)
 demonstration (1.28)

Topic 07
 kvindelig (5.04)
 dag (1.74)
 asylsamtale (1.34)
 ansøg (1.33)
 bidooner (1.25)

Topic 08
 bror (3.32)
 divergere (2.29)
 opholdstilladelse (1.06)
 ansøgere (1.05)
 sandsynliggjore (0.98)

Topic 09
 klager (8.18)
 pas (3.09)
 syrisk (3.02)
 jordan (1.97)
 syrien (1.92)

Visualise the topics produced by NMF:

Latent Semantic Analysis/Indexing:¶

The coherence score for SVD (0.76) is highest with 4 topics.

Build the model with the best number of topics and see them:

Topic 00
 demonstration (1.81)
 kvindelig (1.11)
 bidoon (1.08)
 deltage (1.07)
 bopæl (1.04)

Topic 01
 klager (58.50)
 opholdstilladelse (11.42)
 klagere (6.93)
 syrisk (6.28)
 pas (6.15)

Topic 02
 demonstration (-11.93)
 deltage (-9.14)
 oplysning (-5.78)
 bidoon (-5.65)
 barn (-4.90)

Topic 03
 ansøgere (7.29)
 ægtefælle (2.91)
 følge (2.62)
 mor (2.36)
 barn (2.34)

Kmeans clustering:¶

Try to extract topics from the dataset using clustering techniques.

(array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int32),
 array([ 2, 15,  9, 46, 11, 12,  9, 41,  2, 42]))
<AxesSubplot:xlabel='cluster'>

Wordclouds:¶

WordClouds from the LDA model:¶

WordClouds from the NMF model:¶

WordsClouds from the SVD model:¶

WordClouds from Kmeans clustering:¶